<!-- News.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>创建小组</title>
		<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css">
		<style type="text/css" media="screen">
			body {
				background-color: white;
				overflow: hidden;
			}
			.shadow {
				box-shadow: 0px 0px 10px rgba(0,0,0,.1);
			}
			.header {
				margin-top: 34px;
				margin-right: 20px;
			}
			.mui-input-group:after {
				height: 0px;
			}
			.mui-input-group:before {
				height: 0px;
			}
			.inputBg {
				margin-left: 10px;
				margin-right: 10px;
				margin-top: 10px;
				width: 100%;
				height: 40px;
				line-height: 40px;
				vertical-align: middle;
				padding-left: 10px;
				border: 1px solid #CFD0D0;
				position: relative;
				font-size: 14px;
				color: #313234;
			}
			.imgSet {
				position: absolute;
				left: 8px;
				top: 6px;
				width: 26px;
				height: 26px;
			}
			#name {
				position: absolute;
				left: 25px;
				top: 5px;
				/* width: 100%; */
				height: 30px;
				opacity: 0.3;
				/* background-color: #FEFFFF; */
				color: black;
				font-size: 14px;
				padding-right: 10px;
			}
			.inputSet {
				margin-left: 10px;
				margin-right: -10px;
				height: 40px;
				font-size: 14px;
			}
			.jiantou {
				position: absolute;
				width: 5px;
				height: 10px;
				top: 15px;
				right: 10px;
				font-size: 12px;
			}
			#selectName {
				padding-right: 20px;
			}
			.bottomBtn {
				position: fixed;
				left: 0px;
				right: 0px;
				bottom: 0px;
				width: 100%;
				height: 54px;
				background-color: #FBA95A;
				color: white;
				text-align: center;
				line-height: 54px;
				vertical-align: middle;
			}
			.content {
				margin-left: 10px;
				margin-right: 10px;
				margin-top: 10px;
				line-height: 40px;
				vertical-align: middle;
				padding-left: 10px;
				padding-right: 10px;
				border: 1px solid #CFD0D0;
				position: relative;
				font-size: 14px;
				color: #313234;
			}
			input[type=color], input[type=date], input[type=datetime-local], input[type=datetime], input[type=email], input[type=month], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=time], input[type=url], input[type=week], select, textarea {
				line-height: 30px;
				width: 100%;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div>
		<div class="aui-bar aui-bar-nav base_style_color" style="top: 22px">
			<a class="base_left_item" href="#" onclick="fanhui()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<div class="aui-title">
				创建小组
			</div>
		</div>
		<div class="header">
			<!-- <div class="inputBg"> -->
			<div class="mui-input-row inputSet" >
				<img class="imgSet" src="../../image/iconshuxie.png" alt="">
				<input id="name2" maxlength="20" class="mui-navigate-right" style="color:black;padding-left: 40px;width: 100%;height: 40px;" type="text" placeholder="创建小组名称" >
			</div>
			<div id="selectName" class="inputBg one_line1" onclick="clickSelect()">
				选择小组成员 <img class="jiantou" src="../../image/icon_youcejiantou.png" alt="" onclick="aaaaa()">
			</div>
			<div id="bottomBtn" class="bottomBtn" onclick="createTeam()">
				创建
			</div>
		</div>
		<div id="content" class="content" hidden="hidden"></div>
	</body>
	<script type="text/javascript" src="../../script/jquery.min.js" ></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		var content = "";
		apiready = function() {
			sendBuriedNotifi('0', '小组讨论创建页', '036');
			// $('.inputSet').width(api.winWidth-30);
			// $('#name2').width(api.winWidth-30);
			// $('#name').val("创建小组名称");
			api.addEventListener({
				name : 'refreshClassData'
			}, function(ret, err) {
				if (ret.value) {
					var name = ret.value.name;
					var uid = ret.value.uid;
					// alert("333333"+JSON.stringify(name));
					// alert("444444"+JSON.stringify(uid));
					var str = '';
					for (var i = 0; i < name.length; i++) {
						content += '"' + name[i] + '":' + uid[i] + ',';
						str += name[i] + ',';
					}
					var myself = '"' + $api.getStorage('cfnetUserName') + '":' + $api.getStorage('cfnetppuid') + ',';
					content = myself + content;
					str = $api.getStorage('cfnetUserName') + ',' + str;
					// alert("str"+str);
					content = '{' + content.substring(0, content.length - 1) + '}';
					// alert("content"+content);
					$('#content').show();
					$('#content').text(str.substring(0, str.length - 1));
				}
			});
			// $('#selectName').click(function() {
			// 	ssssss();
			// });
			listenScroll();
			$api.setStorage('tmpSelectedUid', "");
		}
		
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
				vid : api.pageParam.vid
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}
		function listenScroll() {
			var winHeight = $(window).height();
			//获取当前页面高度
			$(window).resize(function() {
				var thisHeight = $(this).height();
				if (winHeight - thisHeight > 40) {
					//当软键盘弹出，在这里面操作
					$("#bottomBtn").css('display', 'none');
				} else {
					$("#bottomBtn").css('display', 'block');
					//当软键盘收起，在此处操作
				}
			});
		}
		
		
		
		

		// function aaaaa () {
		// 	event.stopPropagation();
		// 	alert(121212);
		// }
		function clickSelect() {
	
			api.openWin({useWKWebView:true,
				name : 'SeletctStuWindow',
				url : 'SeletctStuWindow.html',
				pageParam : {
					pid : api.pageParam.pid,
					vid : api.pageParam.vid,
					cid : api.pageParam.cid,
					// cid: 234,
					// vid: 6880155,
					// pid: 3652,
				}
			});
		}

		function createTeam() {
			var title = $('#name2').val();
			if (title == "" || title.length == 0 || title == null) {
				ShowToast("小组名不能为空");
			} else if (content == "" || content.length == 0 || content == null) {
				ShowToast("未选择学生");
			} else {
				showProgress();
				var params = {
					uid : $api.getStorage('cfnetppuid'),
					jid : $api.getStorage('cfnetppjxid'),
					pid : api.pageParam.pid,
					vid : api.pageParam.vid,
					cid : api.pageParam.cid,
					//      	jid:158,
					// uid:113184,
					// cid:234,
					// vid:6880155,
					// pid:3652,
					team_arr : content,
					title : title,
				};
				// alert(JSON.stringify(params));
				cfnetppPOST(url_CreateClassDiscuss, params, true, function(data, status) {//讨论创建小组
					api.hideProgress();
					SendBusinessOperationsLogNotifi('小组讨论创建页', '036', params, params, '', data, '讨论创建小组接口', '036-01')
					if (status == 'success') {
						if (data.code == 200) {
							$api.setStorage('tmpSelectedUid', "");
							// alert(JSON.stringify(data));
							api.openWin({useWKWebView:true,
								name : 'Student_PanelDiscussionWindow',
								url : '../Study/Student_PanelDiscussionWindow.html',
								pageParam : {
									classid : data.data,
									type : 1,
									pid : api.pageParam.pid,
									chapterid : api.pageParam.vid,
									cid : api.pageParam.cid,
									title : api.pageParam.title,
									bewrite : api.pageParam.bewrite,
								},
								reload : true
							});
							api.closeWin({
								name : 'CreateTeam',
							});
						} else if (data.code == 110) {//无数据
							ShowToast("提交失败,选择的学生有的已被选");
						} else if (data.code == 108) {//参数错误
							ShowToast("提交失败,请检查网络重新提交");
							$('#main').hide();
							$('#noData').hide();
							$('#noNet').show();
						}
					} else {
						$('#main').hide();
						$('#noData').hide();
						$('#noNet').show();
					}
				});
			}
		}

		function fanhui() {
			sendBuriedNotifi('1', '小组讨论创建页', '036');
			api.closeWin();
		}
	</script>
</html>